from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.common.action_chains import ActionChains
options = webdriver.EdgeOptions()
options.add_experimental_option("detach", True)
# 使用Firefox浏览器
driver = webdriver.Edge(options = options)
 
# 访问登录页面
driver.get("http://10.0.119.6/login?url=edge-http.microsoft.com%2fcaptiveportal%2fgenerate_204&id=29&user=10.0.109.78&mac=c4:c0:63:bb:04:01&term=0")
 
# 定位用户名输入框
print(dir(driver))
username = driver.find_element(By.NAME,"param[UserName]")
username.send_keys("马红权")
 
# 定位密码输入框
password = driver.find_element(By.NAME,"param[UserPswd]")
password.send_keys("123456")
 
# 定位登录按钮并点击
login_button = driver.find_element(By.ID,"btn_login")
login_button.click()
 
# 程序即将结束时，询问是否关闭浏览器
# choice = input("Do you want to close the browser? (Y/N) ")
# if choice.lower() == "y":
#     # 关闭浏览器
#     driver.quit()
# else:
#     print("Browser will remain open.")

